package server;

/**
 * @date Mar 18, 2011
 * @author Alexander Miner
 * @author Charles Porter
 */
public class ShapeMathHandler {

    public Double getCircleArea( double radius ) {
        return (Math.pow( radius, 2 ) * Math.PI);
    }

    public Double getRectangleArea( double length, double width ) {
        return (length * width);
    }

    //using the Heron Formula, as height isn't given
    public Double getTriangleArea( double s1, double s2, double s3 ) {
        double hp = (s1 + s2 + s3) / 2;     //represents the perimeter divided by 2
        return (Math.sqrt( hp * (hp - s1) * (hp - s2) * (hp - s3) ));
    }

    public Double getRectangleVolume( double length, double width, double height ) {
        return (length * width * height);
    }

    public Double getSphereVolume( double radius ) {
        return ((4 / 3) * Math.pow( radius, 3 ) * Math.PI);
    }

    public Double getCylinderVolume( double radius, double height ) {
        return (Math.PI * Math.pow( radius, 2 ) * height);
    }
}
